using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ESRI.ArcGISExplorer;
using ESRI.ArcGISExplorer.Application;
using ESRI.ArcGISExplorer.Mapping;
using ESRI.ArcGISExplorer.Geometry;
using ESRI.ArcGISExplorer.Data;
using ESRI.ArcGISExplorer.Threading;
using TrackPoint.Data;

namespace TrackPoint
{
    public partial class DockWindow : ESRI.ArcGISExplorer.Application.DockWindow
    {
        private MapDisplay display = null;

        public DockWindow()
        {
            InitializeComponent();

            display = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay;
        }

        private void cmdKml_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = false;
            dlg.Filter = "KML Files (*.kml, *.kmz)|*.kml;*.kmz";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                KmlLayer kml = KmlLayer.Open(dlg.FileName);
                display.Map.ChildItems.Add(kml);
                display.ZoomTo(kml.Extent);
                
            }
        }

        private void cmdSearch_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtSearch.Text))
            {
                IGeoDatabase db = new GeoNamesDatabase();
                db.Query(txtSearch.Text);
            }
        }
    }
}
